package configuration.dataObjects
{
	import mx.collections.ArrayCollection;
	import common.utils.DateManager;
	[Bindable]
	public class ItemLocationCapacityDO
	{
		public var WAREHOUSE:String = "";
		public var INTERNAL_ITEM_CAPACITY_NUM:String = "0";
		public var COMPANY:String = "";
		public var ITEM:String = "";
		public var ITEM_CLASS:String = "";
		public var LOCATION:String = "";
		public var LOCATION_TYPE:String = "";
		public var MAXIMUM_QTY:String = "0";
		public var QUANTITY_UM:String = "";
		public var MINIMUM_RPLN_PCT:String = "0";
		public var USER_STAMP:String = "";
		public var DATE_TIME_STAMP:String = DateManager.GetTodayString();
		
		public function ItemLocationCapacityDO()
		{
		}
		
		public function Init(xmlObj:XML):void{
			if(null == xmlObj)
				return;
			else{
				for each (var itemProp:XML in xmlObj.children()) {
					//Use XML node name to reference matching property in value object				
					this[itemProp.name()] = itemProp;
				}
			}
		}
		
		public function ToXML():XML{
			var xmlObj:XML =
			<ITEM_LOCATION_CAPACITY> 
				<WAREHOUSE>{WAREHOUSE}</WAREHOUSE>
				<INTERNAL_ITEM_CAPACITY_NUM>{INTERNAL_ITEM_CAPACITY_NUM}</INTERNAL_ITEM_CAPACITY_NUM>
				<COMPANY>{COMPANY}</COMPANY>
				<ITEM>{ITEM}</ITEM>
				<ITEM_CLASS>{ITEM_CLASS}</ITEM_CLASS>
				<LOCATION>{LOCATION}</LOCATION>
				<LOCATION_TYPE>{LOCATION_TYPE}</LOCATION_TYPE>
				<MAXIMUM_QTY>{MAXIMUM_QTY}</MAXIMUM_QTY>
				<QUANTITY_UM>{QUANTITY_UM}</QUANTITY_UM>
				<MINIMUM_RPLN_PCT>{MINIMUM_RPLN_PCT}</MINIMUM_RPLN_PCT>
				<USER_STAMP>{USER_STAMP}</USER_STAMP>
				<DATE_TIME_STAMP>{DATE_TIME_STAMP}</DATE_TIME_STAMP>
			</ITEM_LOCATION_CAPACITY>;
			return xmlObj;
		}
		
		public static function getItems(list:XMLList):ArrayCollection
		{
			var ac:ArrayCollection = new ArrayCollection();
			for each(var xml:XML in list)
			{
				var itm:ItemLocationCapacityDO = new ItemLocationCapacityDO();
				itm.Init(xml);
				ac.addItem(itm);
			}
			return ac;
		}		
	}
}